<template>
  <div>
    <div class="webapp">
     <home-header  @tobus="handleChange"></home-header>
     <home-swiper :swiperList="swiperList"></home-swiper>
     <home-icons :iconList="iconList"></home-icons>
     <home-recommend @tobus="handleChange"></home-recommend>
     <home-contact @tobus="handleChange"></home-contact>
     <home-view :show="show" @tobus="handleChange"></home-view>
    </div>
    <div class="pc">
      <header-pc></header-pc>
      <middle-menu></middle-menu>
      <middle-swiper :swiperList="swiperList"></middle-swiper>
      <middle-content></middle-content>
      <menu-alert></menu-alert>
      <pc-bottom></pc-bottom>
    </div>
  </div>
</template>

<script>
import HomeHeader from './components/Header'
import HomeSwiper from './components/Swiper'
import HomeIcons from './components/Icons'
import HomeRecommend from './components/Recommend'
import HomeContact from './components/Contact'
import HomeView from './components/ContactView'
//PC版本
import HeaderPc from './componentsPC/Header'
import MiddleMenu from './componentsPC/MiddleMenu'
import MiddleSwiper from './componentsPC/MiddleSwiper'
import MiddleContent from './componentsPC/MiddleContent'
import MenuAlert from './componentsPC/MenuAlert'
import PcBottom from './componentsPC/PcBottom'
import axios from 'axios'
export default {
  name: 'Home',
  components:{
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeRecommend,
    HomeContact,
    HomeView,
    HeaderPc,
    MiddleMenu,
    MiddleSwiper,
    MiddleContent,
    MenuAlert,
    PcBottom
  },
  data () {
    return {
      city:'',
      swiperList:[],
      iconList:[],
      show:false
    }
  },
  methods :{
      handleChange (){
          this.show =!this.show
      },
      getHomeInfo () {
        axios.get('./api/index.json')
          .then(this.getHomeInfoSucc)
      },
      getHomeInfoSucc (res){
        res =res.data
        if(res.ret && res.data){
          const data = res.data
          this.city = data.city
          this.swiperList=data.swiperList
          this.iconList =data.iconList
        }
      }
  },
  mounted () {
    this.getHomeInfo()
  }
}
</script>

<style lang="stylus" scoped>
  @media (max-width:500px)
    .webapp
      display:block
    .pc
      display:none
  @media (min-width:500px)
    .webapp
      display:none
    .pc
      display:block
</style>
